#ifndef __CMDBUFFER_T_H__
#define __CMDBUFFER_T_H__

#include <stddef.h>
#include "cmd_t.h"
#include "paramBuffer_t.h"
#include "blob_t.h"
#include "config.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_CMD_PER_BLOCK 1000000

typedef struct cmdBlock
{
	cmd_t				commands[MAX_CMD_PER_BLOCK];
	size_t				available;
	struct cmdBlock*	next;
} cmdBlock_t;

typedef struct cmdBuffer
{
	cmdBlock_t*			first;
	size_t				cmdCount;
	paramBuffer_t*		params;
	blob_t*				blob;
} cmdBuffer_t;

typedef void (CALLBACK * pCmdEnumProc)(cmd_t* cmd, void* user);

INLINE cmdBuffer_t*	cmdBuffer_create();
INLINE void			cmdBuffer_addCmd(cmdBuffer_t* buf, void* pFunc, void* args, size_t argsSize);
INLINE void			cmdBuffer_execute(cmdBuffer_t* buf);
INLINE void			cmdBuffer_Enumerate(cmdBuffer_t* buf, pCmdEnumProc pEnum, void* pUserPtr);
INLINE void			cmdBuffer_destroy(cmdBuffer_t* buf);

#ifdef __cplusplus
}
#endif

#endif /* __CMDBUFFER_T_H__ */

